import request from './request.js'

export function getDetali(courseId) {
  return request({
    url: `/courses/getResultDetail`,
    data:{
      courseId:courseId
    },
    method:'GET'
  })
}
// 管理端获取全部反馈
export function getAllBack() {
  return request({
    url: '/feedbacks/getAll',
 
    method: 'GET'
  })
}
export function uploadStudentInfo(list) {
  console.log(Object.prototype.toString.call(list));
  return request({
    url: `/students/import`,
    data:list,
    method: 'POST',
  })
}
export function uploadTecherInfo(list) {
  return request({
    url: `/teachers/import`,
    data:list,
    method: 'POST',
  })
}
export function insetCourse(courseNo,courseName,credits,teacherId) {
  return request({
    url: `/courses/addCourse`,
    data:{
      courseNo:courseNo,
      courseName:courseName,
      credits:credits,
      teacherNo:teacherId
    },
    method: 'POST',
  })
}
export function courseList() {
  return request({
    url: `/courses/courseList`,
    method: 'GET',
  })
}
export function courseArrange(courseId,courseTime,courseLocation,courseEweek,courseBweek,courseItem) {
  return request({
    url: `/courses/setCourse`,
    data:{
      courseTerm:courseItem,
      courseBweek:courseBweek,
      courseEweek:courseEweek,
      courseLocation:courseLocation,
      courseTime:courseTime,
      courseId:courseId
    },
    method: 'POST',
  })
}
export function courseSet(max,selectBegin,selectEnd,courseId) {
  return request({
    url: `/courses/updateCourse`,
    data:{
      max:max,
      selectBegin:selectBegin,
      selectEnd:selectEnd,
      courseId:courseId
    },
    method: 'POST',
  })
}
export function getResult() {
  return request({
    url: `/courses/getResult`,
    method: 'GET',
  })
}
export function deleteResult(courseId,studentId) {
  return request({
    url: `/courses/deleteResult`,
    data:{
      courseId:courseId,
      studentId:studentId
    },
    method: 'POST',
  })
}
export function getTecher() {
  return request({
    url: `/teachers/gets`,
    method: 'GET',
  })
}
export function changeTeacher(item) {
  return request({
    url: `/teachers/update`,
    data:{
      teacherId:item.teacherId,
      teacherNo:item.teacherNo,
      name:item.name,
      phone:item.phone,
      major:item.major,
      courses:item.courses
    },
    method: 'PUT',
  })
}
export function deleteTeacher(teacherId) {
  return request({
    url: `/teachers/del/${teacherId}`, // 使用 teacherId 动态拼接 URL
    method: 'DELETE', // 指定请求方法为 DELETE
  });
}
export function getTeacherByValue(value) {
  return request({
    url: `/teachers/gets/search`, 
    data:{
      search:value
    },
    method: 'POST', 
  });
}
export function getStudent() {
  return request({
    url: `/students/gets`,
    method: 'GET',
  })
}

export function changeStudent(item) {
  return request({
    url: `/students/update`,
    data:{
      studentId:item.studentId,
      studentName:item.studentName,
      studentNo:item.studentNo,
      grade:item.grade,
      major:item.major,
    },
    method: 'PUT',
  })
}

export function deleteStudent(studentId) {
  return request({
    url: `/students/del/${studentId}`, // 使用 teacherId 动态拼接 URL
    method: 'DELETE', // 指定请求方法为 DELETE
  });
}
export function getStudentByValue(value) {
  return request({
    url: `/students/gets/search`, 
    data:{
      search:value
    },
    method: 'POST', 
  });
}
export function studentLogin(studentNo,password) {
  return request({
    url: `/students/login`,
    data:{
      studentNo:studentNo,
      password:password
    },
    method: 'POST',
  })
}

export function teacherLogin(teacherNo,password) {
  return request({
    url: `/teachers/login`,
    data:{
      teacherNo:teacherNo,
      password:password
    },
    method: 'POST',
  })
}

export function studentPwdReset(studentNo,password,newPassword) {
  return request({
    url: `/students/reset`,
    data:{
      studentNo:studentNo,
      password:password,
      newPassword:newPassword
    },
    method: 'PUT',
  })
}

export function teacherPwdReset(studentNo,password,newPassword) {
  return request({
    url: `/teachers/reset`,
    data:{
      teacherNo:studentNo,
      password:password,
      newPassword:newPassword
    },
    method: 'PUT',
  })
}

export function studentGetInfo(studentID) {
  return request({
    url: `/students/get/`+studentID,
    method: 'GET',
  })
}


export function testPost() {
  return request({
    url: `/feedbacks/add`,
    data:{
      studentId:3,
      content:"我的车被谁拖走了",
      feedbackType:"教务类"
    },
    method: 'POST'
  })
}
// 处理反馈
export function dealFeekBack(data) {
  return request({
    url: `/feedbacks/handleFeedback`,
    data:{
      feedbackId:data.feedbackId,
      result:data.result,
      response:data.response
    },
    method: 'PUT'
  })
}

// 管理端获取全部反馈
export function getSearch(type) {
  return request({
    url: '/feedbacks/getByType',
    data:{
      type
    },
    method: 'GET'
  })
}

export function updateStudentInfo(studentId,contact,pwd) {
  return request({
    url: `/students/updateInfo`,
    data:{
      studentId:studentId,
      contact:contact,
      password:pwd
    },
    method: 'PUT'
  })
}

export function getGPABySid(studentId) {
  return request({
    url: '/studentGPA/getBySid',
    data:{
      studentId:studentId
    },
    method: 'GET'
  })
}

export function getHonorsByKeyword(studentId,term) {
  return request({
    url: '/honors/getByKeyword',
    data:{
      studentId:studentId,
      term:term
    },
    method: 'GET'
  })
}

export function getCourseByTerm(studentId,term) {
  return request({
    url: '/courses/getChosenByTerm',
    data:{
      studentId:studentId,
      courseTerm:term
    },
    method: 'GET'
  })
}

export function getCourseInfo(studentId,courseId) {
  return request({
    url: '/courses/getCourseByCourseId',
    data:{
      studentId:studentId,
      courseId:courseId
    },
    method: 'GET'
  })
}

export function getBalance(studentId) {
  return request({
    url: '/campusCards/getBalance',
    data:{
      studentId:studentId,
    },
    method: 'GET'
  })
}

export function getCardTransactions(studentId) {
  return request({
    url: '/cardTransactions/get',
    data:{
      studentId:studentId,
    },
    method: 'GET'
  })
}

export function getFeedbackBySId(studentId) {
  return request({
    url: '/feedbacks/getBySid',
    data:{
      studentId:studentId,
    },
    method: 'GET'
  })
}

export function addFeedback(studentId,content,feedbackType) {
  return request({
    url: '/feedbacks/add',
    data:{
      studentId:studentId,
      content:content,
      feedbackType:feedbackType
    },
    method: 'POST'
  })
}